home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
C/C++ Users Group Library 1996 July
/
C-C++ Users Group Library July 1996.iso
/
vol_100
/
199_01
/
gedio.a
< prev
next >
Wrap
Text File
|
1987-12-15
|
30KB
|
983 lines
;------------------------------------------------------------------
; gedio.a -- Screen and keyboard interface routines for the PC
; Specific to DeSmet C
;
; last modified - 08/02/87
;------------------------------------------------------------------
;------------------------------------------------------------------
; !!! PLEASE NOTE !!!
; This is not quite the same as pcio.a from DeSmet -
; I've made some changes here and there for use with ged.
;
; Renamed for ged 1.10
;
; Have changed all Desmet functions that use x,y co-ords
; to work as col, row.
; Mel Tearle
;------------------------------------------------------------------
;------------------------------------------------------------------
; data starts here
;------------------------------------------------------------------
dseg
; In this implementation, all special and function keys are translated
; to the following values.
; control key translations - mapped into cursor-pad.
up_char equ 5 ;arrow up
down_char equ 24 ;arrow down
left_char equ 19 ;arrow left
right_char equ 4 ;arrow right
bol_char equ 15 ;Home
eol_char equ 16 ;End
pageup_char equ 18 ;PgUp
pagedown_char equ 3 ;PgDn
Del_char equ 7 ;Del
; function key definitions
M1 equ 128
M2 equ 129
M3 equ 130
M4 equ 145
M5 equ 132
M6 equ 133
M7 equ 134
M8 equ 135
M9 equ 136
M10 equ 137
; special keys - toggles and keypress
Insert_key equ 138
Caps_Lock_on equ 139
Caps_Lock_off equ 140
Alt_key equ 146
grey_minus equ 142
grey_plus equ 143
; the table that is used to make the translation
; note - not all used
convert:
db 72, up_char
db 80, down_char
db 75, left_char
db 77, right_char
db 71, bol_char
db 79, eol_char
db 73, pageup_char
db 81, pagedown_char
db 78, grey_plus
db 74, grey_minus
db 82, Insert_key
db 83, Del_char
db 59, M1
db 60, M2
db 61, M3
db 62, M4
db 63, M5
db 64, M6
db 65, M7
db 66, M8
db 67, M9
db 68, M10
db 0, 255 ;illegal character
; equates for bios interface.
; the interrupt and codes for the screen interface interrupt.
video equ 10h ;interrupt for dealing with screen
mode equ 0 ;code for setting new screen mode
curtype equ 1 ;code for setting new cursor type
setcur equ 2 ;code for addressing cursor
readcur equ 3 ;code for reading cursor location
readlp equ 4 ;code for reading light pen position
setpage equ 5 ;code to select active page
scrollup equ 6 ;code to scroll screen up
scrolldn equ 7 ;code to scroll screen nown
readch equ 8 ;code to read a character from screen
writeach equ 9 ;code to write char and attributes
writech equ 10 ;code to write character only
setpal equ 11 ;code to set new setpal or border
wdot equ 12 ;code to write a dot
rdot equ 13 ;code to read a dot
wtty equ 14 ;code to write as if teletype
state equ 15 ;code to find current screen status
; used in set_video
mono_adr equ 0b000h ;mono adapter
graph_adr equ 0b800h ;graphics adapter*
vadrs: dw 0
; the interrupt and codes for the keyboard interface.
keyboard equ 16h ;interrupt 16 to deal with keyboard
cicode equ 0 ;code for reading a character
cstscode equ 1 ;reports if character is ready
kbstatus equ 2 ;get keyboard status - shifts, caplocks
kbset: db 0
; caution: must change column number if 40 column mode
crt_cols equ 80
; variables available to a C88 program
public scr_cols_, scr_rows_, scr_scrollup_, scr_scrolldown_
public scr_mode_, scr_page_, scr_attr_, scr_window_top_
scr_cols_: dw crt_cols ;current number of columns
; note- make 25 for ms-dos and 24 for cp/m as cp/m steals the bottom
; line.
scr_rows_: dw 24 ;current number of rows, for ged, was 25
scr_mode_ db 0 ;current screen mode
scr_page_ db 0 ;current page
scr_attr_ db 7 ;current attributes for screen
;7 is white letters on black
scr_window_top_ db 1 ;first line to scroll, was 0
;------------------------------------------------------------------
; code starts here
;------------------------------------------------------------------
cseg
;-------------------------------------------------------------------------
; SCR_SETUP_ scr_setup must be called before any use of any
; other routine unless the starting mode is 80X25
; character mode (3,4 or 7). Must be called for monochrome
; (mode 7) for scr_curson to set a proper cursor.
;
; Usage: mode = scr_setup();
;-------------------------------------------------------------------------
public scr_setup_
scr_setup_:
push bp
mov bp, sp
mov ah,state ;get current state
int video
mov scr_mode_, al ;current mode
mov cl, ah ;make cols a word
mov ch,0
mov scr_cols_,cx ;40 or 80 columns
mov scr_page_,bh
mov scr_attr_,7 ;set to white chars on black
cmp al, 4 ;see if a character mode
jc got_attr
cmp al, 7 ;7 is for graphics mode
jz got_attr
mov scr_attr_,0 ;attribute is zero in graphics
got_attr:
mov ah,0 ;return int containing mode
push ax ;slight detour
call set_video_ ;get display address
pop ax
pop bp
ret
;-------------------------------------------------------
; SCR_TERM_ do any required termination.
;
; Usage: scr_term();
;-------------------------------------------------------
public scr_term_
scr_term_:
ret
;-------------------------------------------------------
; SCR_SETMODE_ set a new screen mode
;
; Usage: scr_setmode(new mode);
;-------------------------------------------------------
public scr_setmode_
scr_setmode_:
push bp
mov bp,sp
mov al,[bp+4] ;new mode value
mov ah,mode
int video ;set new mode
call scr_setup_ ;remember new values
pop bp
ret
;-------------------------------------------------------
; SCR_XY_ sets cursor at any location.
;
; Usage: scr_xy(column,row);
;-------------------------------------------------------
public scr_xy_
scr_xy_:
push bp ;save from bios
mov bp, sp
mov dx,[bp+4] ;col
mov ax,[bp+6] ;row
mov dh, al
mov bh,scr_page_ ;force page zero
mov ah,setcur ;set cursor location
int video ;call bios
pop bp
ret
;-------------------------------------------------------
; SCR_CLR_ clear entire screen
;
; Usage: scr_clr();
;-------------------------------------------------------
public scr_clr_
scr_clr_:
push bp
mov bp, sp
mov al,0 ;ask for a clear window
xor cx,cx ;start at 0,0
mov dh,byte scr_rows_ ;last line
dec dh
mov dl,byte scr_cols_ ;clear entire width
dec dl ;last column is width-1
mov bh,scr_attr_ ;attributes for new blanks
mov ah,scrollup ;ask for a scrollup to clear
int vide